import React, { Component } from 'react';
import { Row, Col, Card, Button, Popconfirm, notification } from 'antd';
import './main.css';
import axios from '../axios.config';


class Main extends Component {
    constructor(props) {
        super(props);
        this.state = {
            exes: {
                investor: "/resource/exe/vc.investor.exe",
                investment: "/resource/exe/vc.investment.exe",
                liuliang: "/resource/exe/vc.liuliang.exe"
            }
        };
    }
    downloadexe(name) {
        window.open(
            document.location.protocol +
            "//" +
            window.location.host +
            this.state.exes[name]
        );
    }
    reptileInvestor() {
        axios.post("Http/Msg/MainServer.ashx?method=reptile_investor").then(res => {
            if (res.data.flag === "True") {
                notification.success({
                    message: "成功",
                    description: res.data.message
                });
            }
        });
    }
    reptileInvestment() {
        axios.post("Http/Msg/MainServer.ashx?method=reptile_investment").then(res => {
            if (res.data.flag === "True") {
                notification.success({
                    message: "成功",
                    description: res.data.message
                });
            }
        });
    }
    render() {
        return (
            <div id="main_temp">
                <Row gutter={20}>
                    <Col span={6}>
                        <Card>
                            <img src="./images/investor.png" className="image" />
                            <div style={{ padding: "14px" }}>
                                <span>投资机构 爬虫程序</span>
                                <div className="bottom clearfix">
                                    <small>将在每周早上9:30爬取信息</small>
                                    <Popconfirm title="是否下载该应用程序到本地？" onConfirm={() => { this.downloadexe("investor"); }} okText="确定" cancelText="取消">
                                        <Button className="button">下载程序</Button>
                                    </Popconfirm>
                                    <Popconfirm title="是否立即启动该程序？" onConfirm={() => { this.reptileInvestor(); }} okText="确定" cancelText="取消">
                                        <Button className="button">立即执行</Button>
                                    </Popconfirm>
                                </div>
                            </div>
                        </Card>
                    </Col>
                    <Col span={6}>
                        <Card>
                            <img src="./images/investment.png" className="image" />
                            <div style={{ padding: "14px" }}>
                                <span>投融事件 爬虫程序</span>
                                <div className="bottom clearfix">
                                    <small>将在每周早上9:30爬取信息</small>
                                    <Popconfirm title="是否下载该应用程序到本地？" onConfirm={() => { this.downloadexe("investment"); }} okText="确定" cancelText="取消">
                                        <Button className="button">下载程序</Button>
                                    </Popconfirm>
                                    <Popconfirm title="是否立即启动该程序？" onConfirm={() => { this.reptileInvestment(); }} okText="确定" cancelText="取消">
                                        <Button className="button">立即执行</Button>
                                    </Popconfirm>
                                </div>
                            </div>
                        </Card>
                    </Col>
                    <Col span={6}>
                        <Card>
                            <img src="./images/liuliang.png" className="image" />
                            <div style={{ padding: "14px" }}>
                                <span>访问流量 定时任务</span>
                                <div className="bottom clearfix">
                                    <small>将在每天凌晨0:00重置流量</small>
                                    <Popconfirm title="是否下载该应用程序到本地？" onConfirm={() => { this.downloadexe("liuliang"); }} okText="确定" cancelText="取消">
                                        <Button className="button">下载程序</Button>
                                    </Popconfirm>
                                    <Button className="button">敬请期待</Button>
                                </div>
                            </div>
                        </Card>
                    </Col>
                    <Col span={6}>
                        <Card>
                            <img src="./images/liuliang.png" className="image" />
                            <div style={{ padding: "14px" }}>
                                <span>分词搜索 任务调度</span>
                                <div className="bottom clearfix">
                                    <small>后台实时对文章进行分词</small>
                                    <Button className="button">敬请期待</Button>
                                </div>
                            </div>
                        </Card>
                    </Col>
                </Row >
            </div >
        );
    }
}

export default Main;
